<?php
use think\facade\Route;

use app\facade\UserGroup;

Route::group('/money',function() {
    Route::view("/","money/index");

    Route::group("api",function() {
        Route::get("type","money/type");
        Route::get("subtype","money/subtype");
        Route::get("record","money/record");
        Route::get("sum","money/sum");
        Route::post("post","money/post")
            ->middleware(\app\middleware\PowerCheck::class, UserGroup::MoneyPost)
            ->middleware(\app\middleware\JumpLogin::class,'json');// 强制登录
    });
});

Route::group("/",function() {
    Route::view("/","index/index");
});

Route::group("/user",function() {
    Route::group("api",function() {
        Route::get("list","user/list");
        Route::get("group_list","user/group_list");
        Route::get("exit","user/exit");
    });

    // 下面是要求登录才能使用的 api
    Route::group("api",function() {
        Route::group("set",function() {
            Route::post("password","user/set_password");
            Route::get("info","user/get_info");
            Route::post("info","user/set_info");
            Route::post("facer","user/set_facer");
        });

        Route::get("info","user/get_open_info"); // 获取公开的信息
    })->middleware(\app\middleware\JumpLogin::class,'json');
    
    Route::group(function () {
        Route::view("/list","user/list");
        Route::view("/set","user/set");
        Route::get("/","user/index");
        Route::get("/:uid","user/index");
    })->middleware(\app\middleware\JumpLogin::class,'redirect');
});// 所有用户页面都必须先登录

Route::group("post",function() {
    Route::group("api",function() {
        Route::group("get",function() {
            Route::get("info","post/get_info");
            Route::get("content","post/get_content");
            Route::get("list","post/get_list");
            Route::get("type","post/get_type");
        });
        Route::group("post/:pid",function() {
            Route::post("info","post/post_info");
            Route::post("content","post/post_content");
        })->middleware(\app\middleware\JumpLogin::class,'json');
    });

    Route::group(function() {
        // 存在 pid 模糊匹配，放在最后
        Route::get("/list/:type","post/list");
        Route::get("/edit/:pid","post/edit");
        Route::get("/:pid","post/index");
    });
});

Route::group("/auth",function() {
    Route::view("/login","auth/login")->middleware(\app\middleware\JumpOutLogin::class,'redirect');

    Route::group("api",function() {
        Route::post("login","auth/login");
    })->middleware(\app\middleware\JumpOutLogin::class,'json');
});// 所有用户页面都必须先登录